<!-- expects the local variables comment, commentable, and button_name -->
<% if !commentable && @commentable %>
  <% commentable = @commentable %>
<% end %>
<div class="comment_form" id="comment_form_for_<%= commentable.id %>">
	<%= form_for value_for_comment_form(commentable, comment), :html => {:id => "comment_for_#{commentable.id}"} do |f| %>
	  <% if controller.controller_name == "inbox" %>
	  <h4>Reply to <%= get_commenter_pseud_or_name(commentable) %> on <%= commentable_description_link(commentable) %></h4>   
	  <% end %>
	  <% if commentable.is_a?(Tag) %>
	    <%= hidden_field_tag :tag_id, commentable.name %>
	  <% end %>
		<dl>
		<% if logged_in? %>
			<% if current_user.pseuds.count > 1 %>
        <dt><%= f.label "pseud_id_for_#{commentable.id}", ts("Name: ") %></dt>
			  <dd><%= f.collection_select :pseud_id, current_user.pseuds, :id, :name, {:selected => (comment.pseud ? comment.pseud.id.to_s : current_user.default_pseud.id.to_s)}, :id => "comment_pseud_id_for_#{commentable.id}" %></dd>
	    <% else %>
        <dt>Name:</dt>
		    <dd><%= current_user.default_pseud.name %>
        <%= f.hidden_field :pseud_id, :value => "#{current_user.default_pseud.id}", :id => "comment_pseud_id_for_#{commentable.id}" %></dd>
	    <% end %>
    <% elsif logged_in_as_admin? %>
      <dt>Name:</dt>
      <dd><%= current_admin.login %>
          <%= f.hidden_field :name, :value => "#{current_admin.login}", :id => "comment_name_for_#{commentable.id}" %>
          <%= f.hidden_field :email, :value => "#{current_admin.email}", :id => "comment_email_for_#{commentable.id}" %>
      </dd>
	  <% else %>  
      <dt class="landmark">Note:</dt>
    	<dd class="instructions comment_form"><%=ts("All fields are required. Your email address will not be published.") %></dd>
    	<dt><%= f.label "name_for_#{commentable.id}", ts("Name: ") %></dt>
    	<dd><%= f.text_field :name, :value => session[:comment_name], :live => true, :id => "comment_name_for_#{commentable.id}" %></dd>
      <dt><%= f.label "email_for_#{commentable.id}", ts("Email: ") %></dt>
    	<dd><%= f.text_field :email, :value => session[:comment_email],  :live => true, :id => "comment_email_for_#{commentable.id}" %>
	    <p><%= f.hidden_field :ip_address, :value => "#{request.remote_ip}", :id => "comment_ip_address_for_#{commentable.id}" %></p></dd>    
	  <% end %>
      <dt><%= f.label "content_for_#{commentable.id}", ts("Comment: ") %></dt>
      <dd class="module">
        <p class="instructions comment_form"><%= allowed_html_instructions(show_list=false) %></p>
        <p>
          <%= f.text_area :content, :id => "comment_content_for_#{commentable.id}", :class => "comment_form" %>
          <%= generate_countdown_html("comment_content_for_#{commentable.id}", ArchiveConfig.COMMENT_MAX) %>
          <%= live_validation_for_field("comment_content_for_#{commentable.id}",
				      :failureMessage => ts('Brevity is the soul of wit, but we need your comment to have text in it.'),
				      :maximum_length => ArchiveConfig.COMMENT_MAX,
				      :tooLongMessage => ts("must be less than %{count} characters long.", :count => ArchiveConfig.COMMENT_MAX)) %>
        </p>
      </dd>
    </dl>
    <p><input type="hidden" id="controller_name_for_<%= commentable.id %>" name="controller_name" value="<%= @controller_name ||= controller.controller_name %>" />
    </p>
	  <p class="submit">
      <%= f.submit button_name, :id => "comment_submit_for_#{commentable.id}" %>
	    <% if controller.controller_name == 'inbox' %>
        <p id="close-popup" role="navigation" class="navigation"></p>
      <% else %>
        <%= cancel_comment_button(comment, commentable) %>
      <% end %>
	  </p>
  <% end %>
</div> 
<div class="clear"></div>
